home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 31 / Amiga Format CD31 (1998-09-02)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1998-10].iso / -seriously_amiga- / hardware / nsdpatch / nsdpatchinstall.rexx < prev    next >
OS/2 REXX Batch file  |  1998-07-20  |  2KB  |  58 lines

  1. /* This is a magic script to add the correct NSDPatch lines to
  2.  * the S:Startup-Sequence. It takes care to avoid multiple installations
  3.  */
  4.  
  5. options results
  6.  
  7. ssname = "SYS:S/Startup-Sequence"
  8.  
  9.     /* We need it ... */
  10.     if ~show('l', 'rexxsupport.library') then do
  11.         call addlib('rexxsupport.library', 0, -30, 0)
  12.     end
  13.  
  14.     foundnsd = 0
  15.     call open(sfile, ssname, read)
  16.     do while ~eof(sfile)
  17.         line = readln(sfile)
  18.         if line ~= '' then do
  19.             if index(upper(line), "NSDPATCH") > 0 then do
  20.                 foundnsd = 1
  21.             end
  22.         end
  23.     end
  24.     call close(sfile)
  25.  
  26.     if foundnsd = 0 then do
  27.         call open(sfile, ssname, read)
  28.         call open(sofile, ssname".new", write)
  29.         do while ~eof(sfile)
  30.             line = readln(sfile)
  31.             call writeln(sofile, line)
  32.             if line ~= '' then do
  33.                 if index(upper(line), "SETPATCH") > 0 then do
  34.                     foundnsd = 1
  35.                     call writeln(sofile, "; BEGIN NSDPATCH")
  36.                     call writeln(sofile, "IF EXISTS C:NSDPatch")
  37.                     call writeln(sofile, "  C:NSDPatch QUIET")
  38.                     call writeln(sofile, "ENDIF")
  39.                     call writeln(sofile, "; END NSDPATCH")
  40.                 end
  41.             end
  42.         end
  43.         call close(sofile)
  44.         call close(sfile)
  45.  
  46.         if exists(ssname".beforensd") then do
  47.             call delete(ssname".beforensd")
  48.         end
  49.         if exists(ssname) & exists(ssname".new") then do
  50.             call rename(ssname, ssname".beforensd")
  51.         end
  52.         if exists (ssname".new") ~= 0 then do
  53.             call rename(ssname".new", ssname)
  54.         end
  55.     end
  56.  
  57. exit 0
  58.